package com.zw.yzk.kabu.data.repository;

import com.zw.yzk.kabu.data.network.entity.Entity;
import com.zw.yzk.kabu.data.network.task.Task;
import com.zw.yzk.kabu.data.network.ServiceGenerator;
import com.zw.yzk.kabu.data.network.service.AddShippingAddressService;
import com.zw.yzk.kabu.data.network.task.AddShippingAddressTask;

import javax.inject.Inject;

import rx.Observable;
import rx.functions.Func1;

/**
 * Created by zhanwei on 2017/3/12.
 */

public class AddingShippingAddressRepository extends CommonRepository {

    @Inject
    public AddingShippingAddressRepository() {
    }

    @Override
    protected Observable connectServer(Task task) {
        AddShippingAddressService service = ServiceGenerator.createService(AddShippingAddressService.class);

        return service.add((AddShippingAddressTask) task);
    }

    @Override
    protected Func1<Entity, Observable> getServerData() {
        return new Func1<Entity, Observable>() {
            @Override
            public Observable call(Entity entity) {
                return Observable.just(entity);
            }
        };
    }
}
